@extends("layouts.common")
@section("content")


    <div class="row error" style="display: none">
        <div class="col-lg-12">
                <div class="alert alert-danger alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    <h4><i class="icon fa fa-ban"></i> 错误</h4>
                    <ul>
                            <li></li>
                    </ul>
                </div>
        </div>
    </div>


    <div class="row">
        <div class="col-lg-12">
            <h3 class="page-header"><i class="fa fa-table"></i>我的代理</h3>
            <ol class="breadcrumb">
                <li><i class="fa fa-home"></i><a href="/welcome">Home</a></li>
                <li><i class="fa fa-table"></i><a href="/agent">我的代理</a></li>
                <li><i class="fa fa-indent"></i>添加代理</li>
            </ol>
        </div>
    </div>

    <div class="row">

        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h2><i class="fa fa-indent red"></i><strong>添加代理</strong></h2>
                </div>
                <form action="" method="post" enctype="multipart/form-data" class="form-horizontal ">
                <div class="panel-body">
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="text-input">姓名</label>
                            <div class="col-md-9">
                                <input type="text" id="text-input" name="name" class="form-control" value="{{old('name')}}" placeholder="姓名" required>
                                {{--<span class="help-block">This is a help text</span>--}}
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="email-input">邮箱</label>
                            <div class="col-md-9">
                                <input type="email" id="email-input" name="email" class="form-control" value="{{old('email')}}" placeholder="邮箱" required>
                                {{--<span class="help-block">Please enter your email</span>--}}
                            </div>
                        </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="email-input">手机</label>
                        <div class="col-md-9">
                            <input type="text" id="phone-input" name="phone" class="form-control"  value="{{old('phone')}}" placeholder="手机" minlength="11" onkeyup="this.value=this.value.replace(/\D/g,'')" required>
                            {{--<span class="help-block">Please enter your email</span>--}}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="email-input">身份证号</label>
                        <div class="col-md-9">
                            <input type="text" id="card-input" name="card" class="form-control"  value="{{old('card')}}" placeholder="身份证号" minlength="18" required>
                            {{--<span class="help-block">Please enter your email</span>--}}
                        </div>
                    </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="email-input">提成</label>
                            <div class="col-md-9">
                                <select id="select" name="percent" class="form-control" size="1">
                                    <?php
                                    for($i=Auth::user()->percent;$i>=0;$i--){
                                        echo "<option value='".$i."'"; if($i==0) { echo  'selected'; } echo ">".$i."%</option>";
                                    }
                                    ?>
                                </select>
                                {{--<input type="number" id="email-input" name="percent" class="form-control" placeholder="提成"  value="{{old('percent')}}" max="{{Auth::user()->percent}}" required>--}}
                                <span class="help-block">请输入选择数量，最大{{Auth::user()->percent}}%</span>
                            </div>
                        </div>
                        {!! csrf_field() !!}

                </div>
                <div class="panel-footer">
                    <div class="col-md-3"></div>
                    <div> <button type="submit" class="btn btn-sm btn-success"><i class="fa fa-dot-circle-o"></i> Submit</button></div>

                </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        $(function () {
            $(".btn-success").bind("click",function () {
                var phone = $("#phone-input").val();
                var card = $("#card-input").val();
                if(phone.length!='11' &&　!phone.match(/^1[3|5|7|8][0-9]{9}$/)){
                    $(".error li").text("请输入正确手机号");
                    $(".error").show();
                    $("#phone-input").focus();
                    return false;
                }
                if(card.length!='18'){
                    $(".error li").text("请输入正确身份证号");
                    $(".error").show();
                    $("#card-input").focus();
                    return false;
                }
            });
        });
    </script>
    <style>
        td,th{
            text-align: center;
        }
    </style>
@endsection